package window;

import java.awt.*;

public class Bullet extends GameOb {

    double dergree;

    public Bullet(int speed,double x,double y) {
        this.x = x;
        this.y = y;
        this.speed = speed;
        this.width = 10;
        this.height = 10;
        dergree = Math.random() * Math.PI * 2;
    }

    public void drawbillet(Graphics g) {
        Color color = g.getColor();
        g.setColor(Color.YELLOW);
        g.fillOval((int) x, (int) y, width, height);
        x += speed * Math.cos(dergree);
        y += speed * Math.sin(dergree);
        if (x <= 0 || x >= Final.WIDTH) {
            dergree = Math.PI - dergree;
        }
        if (y <= 0 || y >= Final.HEIGHT) {
            dergree = -dergree;
        }
        g.setColor(color);
    }
}
